package com.gexiaobao.pigeon.ui.adapter

import android.graphics.Color
import androidx.core.content.ContextCompat
import com.chad.library.adapter.base.BaseQuickAdapter
import com.gexiaobao.pigeon.R
import com.gexiaobao.pigeon.app.base.DataBindBaseViewHolder
import com.gexiaobao.pigeon.app.model.bean.SearchRaceByNameDetailResponse
import com.gexiaobao.pigeon.databinding.ItemSearchRaceByNameDetailBinding

/**
 * @Author      : hxw
 * @Date        : 2023/8/4 14:20
 * @Describe    :
 */
class SearchRaceByNameDetailAdapter(data: ArrayList<SearchRaceByNameDetailResponse.ListBean>) :
    BaseQuickAdapter<SearchRaceByNameDetailResponse.ListBean, DataBindBaseViewHolder>(R.layout.item_search_race_by_name_detail, data) {

    override fun convert(holder: DataBindBaseViewHolder, item: SearchRaceByNameDetailResponse.ListBean) {
        val binding = DataBindBaseViewHolder.getBinding(holder) as ItemSearchRaceByNameDetailBinding
        binding.data = item
        binding.executePendingBindings()//防止列表抖动

        if (holder.layoutPosition % 2 == 0) {//偶数
            holder.setBackgroundColor(R.id.llItem, ContextCompat.getColor(context, R.color.white))
        } else {
            holder.setBackgroundColor(R.id.llItem, Color.parseColor("#FFF8E6"))
        }
    }
}